import { defineStore } from "pinia";
import { reqGetSearchHotKeyword, reqGetRealSearch, reqSearchInfo, reqSearchCategory, reqSearchPrice } from "@/api/search";
export const useSearchStore = defineStore('search',{
  state: () => {
    return {
      searchHotList: [],
      realSearchList: [],
      searchDetailInfo:[]
    }
  },
  actions: {
    // 热门搜索接口
    async getSearchHotKeyword() {
      const result:any = await reqGetSearchHotKeyword()
      // console.log(result);
      this.searchHotList=result.hotKeywordVOList
    },
    //实时搜索接口
    async getRealSearch(realSearch:string) {
      const result:any = await reqGetRealSearch(realSearch)
      this.realSearchList = result
      // console.log(result);
      
    },
    // 搜索详情信息
    async getSearchInfo(keyWord:string) {
      const result:any = await reqSearchInfo(keyWord)
      this.searchDetailInfo = result
      // console.log(result);
      
    },
    // 获取搜索分类数据
    async getSearchCategory(categoryId:number,keyword:string) {
      const result:any = await reqSearchCategory(categoryId,keyword)
      // console.log(result);
      this.searchDetailInfo = result
    },
    async getSearchPrice(upperPrice: number, floorPrice: number, sortType: number, keyword: string) {
      const result:any = await reqSearchPrice(upperPrice,floorPrice,sortType,keyword)
      // console.log(result);
      this.searchDetailInfo = result
    }

  },
  getters:{}
})